import Vue from 'vue'
import VueRouter from 'vue-router'

const Layout = () => import('../views/layout')

Vue.use(VueRouter)

export const constantRouterMap = [
  {
    path: '/',
    redirect: '/dashboard'
  },
  {
    path: '',
    component: Layout,
    children: [
      {
        path: '/dashboard',
        name: 'Dashboard',
        component: () => import('../views/Dashbord'),
        meta: {
          title: '首页'
        }
      }
    ]
  },
  {
    path: '/system',
    component: Layout,
    meta: { title: '系统管理' },
    children: [
      {
        path: 'version',
        name: 'Version',
        component: () => import('../views/system/version.vue'),
        meta: {
          title: '版本管理',
          keepAlive: true
        }
      },
      {
        path: 'menuList',
        name: 'MenuList',
        component: () => import('../views/system/menuList.vue'),
        meta: {
          title: '菜单配置',
          keepAlive: true
        }
      },
      {
        path: 'optionLog',
        name: 'OptionLog',
        component: () => import('../views/system/optionLog.vue'),
        meta: {
          title: '操作日志'
        }
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login')
  },
  {
    path: '/401',
    component: () => import('../views/errorPage/401')
  },
  {
    path: '/404',
    component: () => import('../views/errorPage/404')
  },
  {
    path: '*',
    redirect: '/404'
  }
]

export default new VueRouter({
  mode: 'hash',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})